<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <!--头部固定引用-->
    <meta charset="utf-8">
    <meta name="full-screen" content="yes">
    <meta name="x5-fullscreen" content="true">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <link rel="stylesheet" href="../../css/base.css">
    <link rel="stylesheet" href="../../css/icon-font.css"/><!--图标-->
    <!--固定引用结束,自定义引用添加在下面-->
    <title>JT2</title>
    <!--页面样式添加在这里，多看看base。css里面的公共样式，大部分常用的都有，避免使用独立css文件为单独页面设置样式，避免随意添加样式到公共样式-->
    <style>
        .user-mmessageHome-redPoint {
            width: 0.16rem;
            height: 0.16rem;
            background: rgba(236, 62, 51, 1);
            border-radius: 0.14rem;
            margin-right: 0.32rem;

        }

        .user-messageHome-module {

            margin-top: 0.16rem;
        }

        .user-messageHome-message {
            height: 1.36rem;
        }

        .user-messageHome-messageImg img {
            margin-left: 0.32rem;
            /*margin-top: 0.34rem;*/
            width: 0.68rem;
            height: 0.68rem;
        }

        .user-messageHome-word {
            border-bottom: 0.5px solid #F2F2F2;
            margin-left: 0.24rem;
            width: 6.24rem;
            height: 1.36rem;
        }

        .user-messageHome-updateTimeInfo {
            margin-right: 0.32rem;
            color: rgba(34, 34, 34, 0.45);
        }

        .user-messageHome-updateTimeSys {
            margin-right: 0.32rem;
            color: rgba(34, 34, 34, 0.45);
        }

        .user-messageHome-updateTimeQue {
            margin-right: 0.32rem;
            color: rgba(34, 34, 34, 0.45);
        }

        .user-messageHome-msgQue {
            color: rgba(34, 34, 34, 0.45);
            margin-right: 0.4rem;
        }

        .user-messageHome-msgSys {
            color: rgba(34, 34, 34, 0.45);
            margin-right: 0.4rem;
        }

        .user-messageHome-msgInfo {
            color: rgba(34, 34, 34, 0.45);
            margin-right: 0.4rem;
        }

        .user-messageHome-messageNumInfo {
            background: rgba(236, 62, 51, 1);
            border-radius: 7px;
            color: rgba(255, 255, 255, 1);
            height: 0.28rem;
            margin-right: 0.32rem;
            padding-left: 0.08rem;
            padding-right: 0.08rem;
        }

        .user-messageHome-messageNumQue {
            background: rgba(236, 62, 51, 1);
            border-radius: 7px;
            color: rgba(255, 255, 255, 1);
            height: 0.28rem;
            margin-right: 0.32rem;
            padding-left: 0.08rem;
            padding-right: 0.08rem;
        }

        .user-messageHome-messageNumSys {
            background: rgba(236, 62, 51, 1);
            border-radius: 7px;
            color: rgba(255, 255, 255, 1);
            height: 0.28rem;
            margin-right: 0.32rem;
            padding-left: 0.08rem;
            padding-right: 0.08rem;
        }

        .user-messageHome-alert {
            margin-left: 0.22rem;
            width: 7.03rem;
            height: 0.96rem;
            background: rgba(44, 104, 255, 1);
            border-radius: 2px;
            margin-bottom: 1.08rem;
        }

        .user-messageHome-alertMessage {
            color: rgba(255, 255, 255, 1);
            line-height: 0.36rem;
            margin-left: 0.16rem;
        }

        .user-messageHome-alertOpen {
            padding-right: 0.16rem;
            padding-left: 0.16rem;
            padding-top: 0.04rem;
            padding-bottom: 0.04rem;
            margin-top: 0.26rem;
            margin-right: 0.16rem;
            margin-bottom: 0.26rem;
            color: rgba(255, 255, 255, 1);
            background: rgba(101, 145, 255, 1);
            border-radius: 0.22rem;
        }

        .user-messageHome-messageImg {
            color: rgba(255, 255, 255, 0.38);
        }

        .user-messageHome-alertImg {
            color: rgba(255, 255, 255, 0.38);
        }

        .user-messageHome-alertLeft {
            margin-left: 0.16rem;
            margin-right: 0.16rem;
        }

        .user-messageHome-sysRoleT {
            margin-top: 0.04rem;
        }

        .user-messageHome-msgRoleT {
            margin-top: 0.04rem;
        }

        .user-messageHome-infoRoleT {
            margin-top: 0.04rem;
        }

        .user-messageHome-redNum {
            height: 0.28rem;
        }
    </style>
</head>
<!--尽量不要在body上添加样式，除了背景色-->
<body>
<div class=" flex-column ff400 h-100-p">
    <!--头部部分-->
    <div class="placeholder-top">
        <!--状态栏-->
        <div class="bg-main status-bar pos-f"></div>
        <!--导航栏-->
        <div class="bg-main nav-bar pos-f flex-row justify-content-between c-white align-items-center">
            <div class="left-bar" onclick="clickBack()">
                <span class="iconfont iconfanhui1 fs16"></span>
            </div>
            <div class="flex-row center-bar fs16 ff500">我的消息</div>
            <div class="right-bar">
            </div>
        </div>
    </div>
    <!--功能模块-->
    <div class="flex-column user-messageHome-module align-items-center flex-1">
        <!--资讯消息模块-->
        <div class="user-messageHome-message flex-row bg-white align-items-center" onclick="goMsgInfo()">
            <!--资讯消息图标-->
            <div class="user-messageHome-messageImg"><img src="../../images/user/messageHome-infoMessage.png"></div>
            <div class="user-messageHome-word flex-column justify-content-center">
                <div class="user-messageHome-role0 flex-row justify-content-between align-items-center">
                    <div class="user-messageHome-title fs15 ff500">资讯消息</div>
                    <div class="user-messageHome-updateTimeInfo fs12"></div>
                    <div class="message-home-isred0"></div>
                </div>
                <div class="user-messageHome-infoRoleT flex-row justify-content-between">
                    <div class="user-messageHome-msgInfo fs12 line1"></div>
                    <!--                    <div class="user-messageHome-messageNumInfo fs10"></div>-->
                </div>
            </div>

        </div>
        <!--系统公告模块-->
        <div class="user-messageHome-message flex-row bg-white align-items-center" onclick="goPubAlert()">
            <!--系统公告图标-->
            <div class="user-messageHome-messageImg"><img src="../../images/user/messageHome-publicMessage.png"></div>
            <div class="user-messageHome-word flex-column justify-content-center">
                <div class="user-messageHome-role1 flex-row justify-content-between align-items-center">
                    <div class="user-messageHome-title fs15 ff500">系统公告</div>
                    <div class="user-messageHome-updateTimeSys fs12"></div>
                    <div class="message-home-isred1"></div>
                </div>
                <div class="user-messageHome-sysRoleT flex-row justify-content-between">
                    <div class="user-messageHome-msgSys fs12 line1"></div>
                    <!--                    <div class="user-messageHome-messageNumSys fs10"></div>-->
                </div>
            </div>
        </div>
        <!--问题/意见反馈进度模块-->
        <div class="user-messageHome-message flex-row bg-white align-items-center" onclick="goFeedBack()">
            <!--问题反馈进度图标-->
            <div class="user-messageHome-messageImg"><img src="../../images/user/messageHome-QA.png"></div>
            <div class="user-messageHome-word flex-column justify-content-center">
                <div class="user-messageHome-role2 flex-row justify-content-between align-items-center">
                    <div class="user-messageHome-title fs15 ff500">问题/意见反馈进度</div>
                    <!--问题最新答复时间-->
                    <div class="user-messageHome-updateTimeQue fs12"></div>
                </div>
                <div class="user-messageHome-msgRoleT flex-row justify-content-between">
                    <div class="user-messageHome-msgQue line1 fs12"></div>
                    <div class="message-home-msgnum"></div>
                    <!--                    <div class="user-messageHome-messageNumQue fs10"></div>-->
                </div>
            </div>
        </div>
    </div>
    <!--消息推送开启提醒-->
    <div class="message-home-send">

    </div>

</div>
<!--具体代码-->
</body>
<!--下面四个文件为固定引用，自己根据情况调整路径，不要跟换引入顺序，其他引用添加在后面-->
<script src="../../js/dict.js"></script>
<script src="../../js/jquery-3.4.1.min.js"></script>
<script src="../../js/checkJsBridge.js"></script>
<script src="../../js/utils.js"></script>
<!--固定引用结束-->
<script src="../../js/date.js"></script>
<script src="../../js/api.js"></script>
<!--避免一个页面包含过多功能，减少js重绘页面，推荐分功能，分页面-->
<script>
    let pm = {
      infoIsRead: true,
      sysNoticeIsRead: false,
      sysMsgState: false
    }

    /*固定页面初始化方法，用于替代$(function(){}),param为url参数，Object类型*/
    function initPage(params) {
      //状态栏自适应
      Utils.sbhAdaptive()

      reLoadPage()
    }

    /*页面所在窗口由后台前台时触发的方法,param为url参数，Object类型*/
    function startPage(params) {
      reLoadPage()
    }

    function reLoadPage() {
      //获取用户反馈相关消息
      getUserFeedBack()
      //获取资讯与公告总体阅读状态
      getMsgReadStatus()
      //获取当前用户的消息接收状态，判定是否需要弹出消息开启通知
      getReceiveState()
    }

    //跳转到资讯消息界面
    function goMsgInfo() {
      //页面跳转
      jsBridge.openWindow('html/user/message-info.html', {}, {noBar: false})
    }

    //跳转到系统公告界面
    function goPubAlert() {
      //页面跳转
      jsBridge.openWindow('html/user/notice.html', {}, {noBar: false})
    }

    //跳转到问题反馈界面
    function goFeedBack() {
      jsBridge.openWindow('html/user/feedback-schedule.html', {}, {noBar: false})
    }

    //获取当前用户反馈消息中已答复未阅读的数量
    function getUnreadNums() {
      Server.messageHome.getUnreadNums().then(
        function (data) {
          let unreadNums = data.unreadNums
          if (unreadNums > 0) {
            let messageNumQue = `<div class="user-messageHome-messageNumQue fs10 flex-column justify-content-center align-items-center">
                                <div class="user-messageHome-redNum flex-column justify-content-center align-items-center"><div>${unreadNums}</div></div>
                            </div>`
            $('.message-home-msgnum').html(messageNumQue)
          } else {
            $('.message-home-msgnum').html(``)
          }
        }
      ).catch(jsBridge.log)
    }

    //获取当前用户反馈消息中最新已答复未阅读的答复时间与标题
    function getLastUnreadTimeTitle() {
      Server.messageHome.getLastUnreadTimeTitle().then(
        function (data) {
          if (data.lastUnreadTime) {
            let showLastUnreadTime = DateUtils.int2TimeDesc(data.lastUnreadTime)
            if (showLastUnreadTime.length === 16) {
              showLastUnreadTime = showLastUnreadTime.substr(5, 5)
            }
            $('.user-messageHome-updateTimeQue').html(showLastUnreadTime)
          } else {
            $('.user-messageHome-updateTimeQue').html(``)
          }
          if (data.lastInfoTitle) {
            $('.user-messageHome-msgQue').html(data.lastInfoTitle)
          } else {
            $('.user-messageHome-msgQue').html(``)
          }
        }
      ).catch(jsBridge.log)
    }

    //跳转到系统消息接收设置页面
    function goMsgSet() {
      jsBridge.setSysMsgOpen()
    }

    // 获取用户反馈消息
    function getUserFeedBack() {
      //获取当前用户反馈消息中最新已答复未阅读的答复时间与标题
      getLastUnreadTimeTitle()

      //获取当前用户反馈消息中已答复未阅读的数量
      getUnreadNums()
    }

    //获取资讯与公告总体阅读状态
    function getMsgReadStatus() {
      jsBridge.getMsgReadStatus().then(data => {
        pm.infoIsRead = data.infoIsRead
        pm.sysNoticeIsRead = data.sysNoticeIsRead
        if (pm.infoIsRead) {
          let messageNumInfo = '<div class="user-mmessageHome-redPoint align-items-center fs10"></div>'
          $('.message-home-isred0').html(messageNumInfo)
        } else {
          let messageNumInfo = ''
          $('.message-home-isred0').html(messageNumInfo)
        }
        if (pm.sysNoticeIsRead) {
          let sysNums = '<div class="user-mmessageHome-redPoint flex-row fs10 align-items-center"></div>'
          $('.message-home-isred1').html(sysNums)
        } else {
          let sysNums = ''
          $('.message-home-isred1').html(sysNums)
        }
      })
    }

    //获取当前用户的消息接收状态，判定是否需要弹出消息开启通知
    function getReceiveState() {
      jsBridge.getSysMsgState().then(data => {
        pm.sysMsgState = data.sysMsgState
        //	未开启消息通知
        if (!pm.sysMsgState) {
          htmlStr = `            <!--消息推送开启提醒-->
                <div class="user-messageHome-alert flex-row justify-content-between align-items-center">
                <div class="user-messageHome-alertLeft flex-row align-items-center">
                    <!--感叹号图标-->
                <div class="user-messageHome-alertImg iconfont icontishi-01 fs12"></div>
                <div class="user-messageHome-alertMessage fs13">新消息提醒未开启，无法接受消息推送</div>
                </div>
                <div class="user-messageHome-alertOpen fs12" onclick="goMsgSet()">立即开启</div>
                </div>`
          $('.message-home-send').html(htmlStr)
        } else {
          htmlStr =

                ``


          $('.message-home-send').html(htmlStr)
        }
      }
      )
    }


</script>
</html>

<!--        将来肯定能用上的代码
desc: 用于显示资讯消息与系统公告最新未读标题、未读数与时间，勿删谢谢QAQ       -------雪小飞

      //从缓存中获取资讯消息的未读数
      getUnreadInfoMsgNumsCache()

      //从缓存中获取资讯消息的最新未读标题
      getUnreadInfoMsgTitleCache()

      //从缓存中获取资讯消息的最新未读推送时间
      getUnreadInfoMsgTimeCache()

      //从缓存中获取系统公告的未读数
      getUnreadSysNumsCache()

      //从缓存中获取系统公告的最新未读标题
      getUnreadSysTitleCache()

      //从缓存中获取系统公告的最新未读推送时间
      getUnreadSysTimeCache()

 //从缓存中获取资讯消息的未读数
    function getUnreadInfoMsgNumsCache() {
      jsBridge.getData('unreadInfoMsgNumsCache').then(unreadInfoMsgNumsCache => {
        if (unreadInfoMsgNumsCache && unreadInfoMsgNumsCache.length > 0) {
          let messageNumInfo = '<div class="user-messageHome-messageNumInfo fs10">' + unreadInfoMsgNumsCache + '</div>'
          $('.user-messageHome-infoRoleT').append(messageNumInfo)
        }
      })
    }

    //从缓存中获取资讯消息的最新未读标题
    function getUnreadInfoMsgTitleCache() {
      jsBridge.getData('unreadInfoMsgTitleCache').then(unreadInfoMsgTitleCache => {
        $('.user-messageHome-msgInfo').html(unreadInfoMsgTitleCache)
      })
    }

    //从缓存中获取资讯消息的最新未读推送时间
    function getUnreadInfoMsgTimeCache() {
      jsBridge.getData('unreadInfoMsgTimeCache').then(unreadInfoMsgTimeCache => {
        let showLastUnreadTime = DateUtils.int2TimeDesc(unreadInfoMsgTimeCache)
        if (showLastUnreadTime.length === 16) {
          showLastUnreadTime = showLastUnreadTime.substr(5, 5)
        }
        $('.user-messageHome-updateTimeInfo').html(showLastUnreadTime)
      })
    }

    //从缓存中获取系统公告的未读数
    function getUnreadSysNumsCache() {
      jsBridge.getData('unreadSysNumsCache').then(unreadSysNumsCache => {
        if (unreadSysNumsCache && unreadSysNumsCache.length > 0) {
          let sysNums = '<div class="user-messageHome-messageNumSys flex-row fs10 justify-content-center">' + unreadSysNumsCache + '</div>'
          $('.user-messageHome-sysRoleT').append(sysNums)
        }
      })
    }

    //从缓存中获取系统公告的最新未读标题
    function getUnreadSysTitleCache() {
      jsBridge.getData('unreadSysTitleCache').then(unreadSysTitleCache => {
        $('.user-messageHome-msgSys').html(unreadSysTitleCache)
      })
    }

    //从缓存中获取系统公告的最新未读推送时间
    function getUnreadSysTimeCache() {
      jsBridge.getData('unreadSysTimeCache').then(unreadSysTimeCache => {
        let showLastUnreadTime = DateUtils.int2TimeDesc(unreadSysTimeCache)
        if (showLastUnreadTime.length === 16) {
          showLastUnreadTime = showLastUnreadTime.substr(5, 5)
        }
        $('.user-messageHome-updateTimeSys').html(showLastUnreadTime)
      })
    }
-->
